package com.sinopec.yelofixedreader.stock.inn.presenter

import com.sinopec.basemodule.http.CommonObserver
import com.sinopec.basemodule.http.ExceptionEngine
import com.sinopec.yelofixedreader.stock.inn.api.StockInApi
import com.sinopec.yelofixedreader.stock.inn.contract.StockInDetailContract

/**
 * @author lwj
 * @ClassName: StockInDetailPresenter
 * @Description: 入库详情
 */
class StockInDetailPresenter(view: StockInDetailContract.View) :
    StockInDetailContract.Presenter(view) {

    /**
     * 确认入库完成
     */
    override  fun confirmStockInOrderFinish(id: Long) {
        val resultObservable = StockInApi.confirmStockInOrderFinish(id)
        toSubscribe(resultObservable, object : CommonObserver<Any?>(mView.context) {
            override fun onNext(s: Any) {
                mView.context.finish()
                mView.showMessage("操作成功！")
            }

            override fun onError(t: ExceptionEngine.ResponseThrowable) {
//                mView.context.finish()
//                mView.showMessage("操作成功！")
                mView.showMessage(t.message)
            }
        })
    }
}